{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/min-stack\n",
    "\n",
    "\n",
    "\n",
    "Runtime: 20 ms, faster than 8.33% of Rust online submissions for Min Stack.\n",
    "Memory Usage: 5.5 MB, less than 83.33% of Rust online submissions for Min Stack.\n",
    "\n",
    "\n",
    "\n",
    "```rust\n",
    "struct MinStack {\n",
    "    stack: Vec<i32>\n",
    "}\n",
    "\n",
    "/** \n",
    " * `&self` means the method takes an immutable reference.\n",
    " * If you need a mutable reference, change it to `&mut self` instead.\n",
    " */\n",
    "impl MinStack {\n",
    "\n",
    "    /** initialize your data structure here. */\n",
    "    fn new() -> Self {\n",
    "        return MinStack{stack: Vec::new()};\n",
    "    }\n",
    "    \n",
    "    fn push(& mut self, x: i32) {\n",
    "        self.stack.push(x);\n",
    "    }\n",
    "    \n",
    "    fn pop(& mut self) {\n",
    "        self.stack.pop();\n",
    "    }\n",
    "    \n",
    "    fn top(&self) -> i32 {\n",
    "        return *self.stack.last().unwrap();\n",
    "    }\n",
    "    \n",
    "    fn get_min(&self) -> i32 {\n",
    "        return *self.stack.iter().min().unwrap();\n",
    "    }\n",
    "}\n",
    "\n",
    "fn main() {\n",
    "    println!(\"{} is the best.\", \"yingshaoxo\".to_string() as String);\n",
    "}\n",
    "```\n",
    "\n",
    "\n",
    "Spent 1 hour\n",
    "\n",
    "Rust is a strict programming language. (You'll get a lot of error when you write your code, but once it is done, no error would appear as it runs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Rust",
   "language": "rust",
   "name": "rust"
  },
  "language_info": {
   "codemirror_mode": "rust",
   "file_extension": ".rs",
   "mimetype": "text/rust",
   "name": "Rust",
   "pygment_lexer": "rust",
   "version": ""
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
